import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'
import About from '@/components/About'
import User from '@/components/User'

const UserDetail = () => import('../components/UserDetail.vue')
const HomeMessage = () => import('../components/HomeMessage.vue')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      children: [
        { path: '', component: HomeMessage },
        { path: 'message', component: HomeMessage },
        { path: 'detail', component: UserDetail }
      ]
    },
    {
      path: '/about',
      name: 'about',
      component: About
    },
    {
      path: '/user/:userId',
      name: 'user',
      component: User,
      children: [
        {
          path: '',
          component: UserDetail
        },
        {
          path: 'detail',
          component: UserDetail
        }
      ]
    }
  ],
  mode: 'history'
})